﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.MailCategoryViewModel>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Chuyên mục mail
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
    Chuyên mục mail
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Thêm mới", "/mailcategory/create/"  , "new") %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <form action="/mailcategory" method="post" name="adminForm">
    <table width="100%">
        <tr>
            <td align="left">
                Tìm nhanh
                <%= Html.TextBox("Keyword", Model.Keyword) %>
                <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
            </td>
            <td align="right">
                <%--<%=Html.TreeViewList("CatID", Model.Categories, "-- Chuyên mục --", new { onchange = "document.adminForm.submit();" })%>--%>
                <%=Html.DropDownList("CurrentPubStatus", Model.ListStatusPub, "-- Trạng thái hiển thị --", new { onchange = "document.adminForm.submit();" })%>
            </td>
        </tr>
    </table>
    <table width="100%" class="adminlist">
        <tr>
            <th width="10" align="right">
                STT
            </th>
            <th width="30">
            </th>
            <th width="30">
            </th>
            <th>
                <%= Html.Sort("Tên chuyên mục","Name", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
            </th>
            <th width="150">
			    <%=Html.Sort("Thuộc chuyên mục", "ParentID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
			</th>
            <th style="width: 90px">
                <%= Html.Sort("Ngày thêm", "AddDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
            </th>
            <th style="width: 40px; color: #1D60FF;">
                PubYN
            </th>
            <th width="30">
                <%= Html.Sort("ID", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
            </th>
        </tr>
        <% 
            int i = 0;
            foreach (var item in Model.MailCategories)
            {
                i++;
        %>
        <tr>
            <td align="right">
                <%= i.ToString() %>
            </td>
            <td align="center">
                <%= Html.ActionImage("Sửa", "icon-24-edit.png", "mailcategory", "edit", new Dictionary<string, object>() { { "id", item.ID } })%>
            </td>
            <td align="center">
                <%= Html.ActionImage("Xóa", "icon-24-delete.png", "mailcategory", "delete", new Dictionary<string, object>() { { "id", item.ID } })%>
            </td>
            <td>
                <%= Html.ActionLink(item.Name, "details", new { id = item.ID })%>
            </td> 
            <td><%=Html.Encode(item.MailCategoryParent != null ? item.MailCategoryParent.Name : string.Empty)%></td>          
            <td>
                <%= Html.Encode(item.AddDate.ToString("dd/MM/yyyy"))%>
            </td>
            <td align="center">
                <img alt="" id="imgActiveYN_<%= item.ID %>" onclick="ChangeActiveYN(<%= item.ID %>);"
                    value="<%= item.PubYN %>" src="<%= item.PubYN ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
            </td>
            <td>
                <%= Html.Encode(item.ID) %>
            </td>
        </tr>
        <% } %>
    </table>
    <%= Html.Hidden("order")%>
    <%= Html.Hidden("orderDir")%>
    <table width="100%">
        <tr>
            <td align="center">
                <div class="pager">
                    <label>
                        Hiển thị #</label>
                    <%
                        int[] pageSizeList = { 1, 5, 10, 15, 20, 25, 50, 100 };
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.MailCategories.PageSize), new { onchange = "document.adminForm.submit();" })%>
                    <%= Html.Pager(Model.MailCategories.PageSize, Model.MailCategories.PageNumber, Model.MailCategories.TotalItemCount)%>
                </div>
            </td>
        </tr>
    </table>
    </form>
    <% } %>
    
    

    <script type="text/javascript">
        function ChangeActiveYN(id) {
            var obj = $("#imgActiveYN_" + id);
            ApplyChangeYN("/AjaxData/UpdateMailCategoryPubYN/" + id + '/' + obj.attr("value"), id, obj);
        }
    </script>

</asp:Content>
